package com.winter.Controller;

import com.aliyuncs.exceptions.ClientException;
import com.winter.sms.SmsService;
import com.winter.util.Result;
import com.winter.util.ResultCode;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("v1/verification")
public class VerificationController {

    @Autowired
    private SmsService smsService;

    /**
     * 发送验证码
     */
    @GetMapping("send_code")
    public Result sendMsgCode(String phone, String type) {
        try {
            return smsService.sendMsgCode(phone, type);
        } catch (ClientException e) {
            e.printStackTrace();
        }
        return Result.failure(ResultCode.PARAM_IS_BLANK, "短信发送失败");
    }

}
